package com.shenyong.ladmin.controller;

import com.shenyong.ladmin.logConfig.Log;
import com.shenyong.ladmin.logConfig.OperationType;
import com.shenyong.ladmin.result.Page;
import com.shenyong.ladmin.service.CommentService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 后台评论管理
 * commentAll
 * deleteComment
 */
@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;
    @RequiresAuthentication
    @ApiOperation(value = "查询评论", notes = "分页查询评论记录", produces = "application/json")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "起始行", required = false, dataType = "int")
            , @ApiImplicitParam(name = "limit", value = "显示多少条数据", required = false, dataType = "int")})
    @RequestMapping("commentAll")
    public Map<String,Object> commentAll(Page page){
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("msg","");
        map.put("code",0);
        map.put("count",commentService.commentCount(page));
        map.put("data",commentService.commentAll(page));
        return map;
    }
    @RequiresAuthentication
    @Log(describe = "删除用户评论",operationType= OperationType.DELETE)
    @RequestMapping("deleteComment")
    public int deleteComment(int comment_id){
        return commentService.deleteComment(comment_id);
    }

}
